package com.niit.guet.w13.session3.homework;

import java.util.Scanner;

/**
 *  用户登录验证。验证次数最多3次
 * @author Administrator
 *
 */
public class Ex3 {
public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	int loginTime = 3;
	while(loginTime>0) {
		loginTime--;
		System.out.println("请输入用户名：");
		String username = scanner.next();
		System.out.println("请输入密码：");
		String password = scanner.next();
		if("trout".equals(username)&&"123456".equals(password)) {
			System.out.println("登录成功");
			break;
		}else {
			if(loginTime == 0) {
				System.out.println("登录失败，次数已用尽，系统锁定");
			}else{
				System.out.println("登录失败，还剩"+loginTime+"次机会");
			}
		}
		
	}
	scanner.close();
}
}
